﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Gammar.Digger.BLL;
using Gammar.Digger.SystemFramework;
using Gammar.Digger.Entity;
using Gammar.Digger.BLL.Common;
using System.Collections.Generic;

public partial class plugin_validate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = Request.QueryString["pluginid"];
           // string listUrl = Request.QueryString["ru"];

            if (string.IsNullOrEmpty(id))
            {
                Response.Write("invalid plugin id");
                Response.End();
            }
            else
            {
               PluginValidate.PluginValidResult result=  PluginValidate.DoValid(id);

               Response.Write("插件编号："+result.PluginId+"<br>");

               Response.Write("插件校验结果：" +PluginValidate.FormatResult(result.Result) + "<br>");
               Response.Write("开始页：" + result.StartUrl + "<br>");
               Response.Write("详情页：" + result.DetailUrl + "<br>");

               Response.Write("-----------item result start-----------------<br>");

               foreach (KeyValuePair<string,PluginValidate.ItemResult> item in result.ItemResults)
               {
                   Response.Write(item.Key + "-----------" + PluginValidate.FormatItemResult(item.Value) + "<br>");
               }


               Response.Write("-----------item result end-----------------");

               if (result.Result== PluginValidate.Result.valid)
               {
                   PluginManagement.UpdatePluginStatus(result.PluginId.ToString(), true);
               }

               if (result.Result!= PluginValidate.Result.valid&&result.Result!= PluginValidate.Result.NotFind)
               {
                   PluginManagement.UpdatePluginStatus(result.PluginId.ToString(), false);
               }

               //Response.Write("<script>setTimeout('parent.location.reload();',5000);</script>");

            }
        }
    }
}
